package com.mmlc.meimei.lichengkongjian.mine;

import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.androidnetframe.httputil.BaseRequestFilterLayer;
import com.androidnetframe.responsejavabean.RequestError;
import com.mmlc.inter.InterActivity;
import com.mmlc.meimei.lichengkongjian.R;
import com.mmlc.meimei.lichengkongjian.been.RefundDetailBean;
import com.mmlc.network.filter.RefundDetailRequestFilter;
import com.mmlc.network.responsebean.RefundDetailResponseBean;
import com.mmlc.widget.TitleBarView;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class RefunddetailActivity extends InterActivity {


    @InjectView(R.id.tb_titleBar)
    TitleBarView tbTitleBar;
    @InjectView(R.id.tv_money)
    TextView tvMoney;
    @InjectView(R.id.tv_returnMoney)
    TextView tvReturnMoney;
    @InjectView(R.id.tv_refundReason)
    TextView tvRefundReason;
    @InjectView(R.id.tv_applyTime)
    TextView tvApplyTime;
    @InjectView(R.id.tv_refundStateNone)
    TextView tvRefundStateNone;
    @InjectView(R.id.tv_stateFinish)
    TextView tvStateFinish;
    @InjectView(R.id.tv_stateDesc)
    TextView tvStateDesc;
    @InjectView(R.id.rootView)
    RelativeLayout rootView;

    @Override
    protected int initContentView() {
        return R.layout.activity_refunddetail;
    }

    @Override
    protected void initView() {
        ButterKnife.inject(this);
        processData();
    }

    String order_id;
    private void processData() {
        order_id = getIntent().getStringExtra("order_id");

        tbTitleBar.setCenterName("退款详情");
        requestNet();
    }

    private void requestNet() {
        final RefundDetailRequestFilter filter = new RefundDetailRequestFilter(this);
        filter.requestBean.order_id = order_id;
        filter.offerErrorParams(rootView);
        filter.sendRequest(new BaseRequestFilterLayer.AccessResultFromFilter<RefundDetailResponseBean>() {

            @Override
            public void onSuccess(RefundDetailResponseBean result) {
                RefundDetailBean bean = filter.responseBean;

                if(bean != null){
                    initUI(bean);
                }

            }

            @Override
            public void onFailed(View errorLayout, RequestError serverError, int failedType) {

            }
        });


    }

    private void initUI(RefundDetailBean bean) {
        tvMoney.setText("¥ "+bean.money);
        tvReturnMoney.setText("¥ "+bean.returnMoney);
        tvRefundReason.setText("退款原因: "+bean.refundReason);
        tvApplyTime.setText("申请时间: "+bean.applyTime);
        tvStateFinish.setText(bean.refundState);
        tvStateDesc.setText(bean.refundStateDesc);
    }


}
